package cn.edu.lsu.integratedsurvey.bean.vo;

import cn.edu.lsu.integratedsurvey.bean.History;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 学生综测记录返回VO对象
 *
 * @author Jasmine-drs
 * @date 2024/5/1 20:10
 */

@Data
public class HistoryInfoVo {
	@NotNull(message = "[id索引]不能为空")
	@ApiModelProperty("综测历史记录id")
	Integer id;

	@NotBlank(message = "[姓名]不能为空")
	@Size(max = 20, message = "编码长度不能超过20")
	@ApiModelProperty("姓名")
	private String name;

	@NotBlank(message = "[学号]不能为空")
	@Size(max = 11, message = "编码长度不能超过11")
	@ApiModelProperty("学号")
	private String studentNumber;

	@NotBlank(message = "[活动名称]不能为空")
	@Size(max = 255, message = "编码长度不能超过255")
	@ApiModelProperty("活动名称")
	private String subtype;

	@NotNull(message = "[加减分]不能为空")
	@ApiModelProperty("加减分")
	private Double value;

	@NotNull(message = "[七大类的类型]不能为空")
	@ApiModelProperty("七大类的类型：0德育，1智育，2体育，3美育，4劳动教育，5创新创业能力，6突出贡献")
	private Integer type;

	@NotNull(message = "[操作员姓名]不能为空")
	@ApiModelProperty("操作员姓名")
	private String operatorName;

	@NotNull(message = "[操作员部门]不能为空")
	@ApiModelProperty("操作员部门")
	private String operatorDepartment;

	@NotNull(message = "[创建时间]不能为空")
	@ApiModelProperty(value = "创建时间", required = true)
	private LocalDateTime createTime;

	/**
	 * 将History对象转换为HistoryInfoVo对象
	 *
	 * @param history 综测记录对象
	 * @return 前端可见对象
	 */
	public static HistoryInfoVo convertToVo(History history) {
		HistoryInfoVo historyInfoVo = new HistoryInfoVo();
		historyInfoVo.setId(history.getId());
		historyInfoVo.setName(history.getName());
		historyInfoVo.setStudentNumber(history.getStudentNumber());
		historyInfoVo.setSubtype(history.getSubtype());
		historyInfoVo.setValue(history.getValue());
		historyInfoVo.setType(history.getType());
		historyInfoVo.setOperatorName(history.getOperatorName());
		historyInfoVo.setOperatorDepartment(history.getOperatorDepartment());
		historyInfoVo.setCreateTime(history.getCreateTime());
		return historyInfoVo;
	}
}
